package com.mobile.dao;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Example;
import org.hibernate.criterion.Order;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class BaseDAO extends HibernateDaoSupport {
	public List getObjectsByIds(Object o,int start,int pageSize){
		Example example=Example.create(o)
								.enableLike()
								.ignoreCase();
		DetachedCriteria criteria = DetachedCriteria
									.forClass(o.getClass())
									.add(example)
									.addOrder(Order.asc("uniqueCode"));
		return getHibernateTemplate().findByCriteria(criteria, start, pageSize);
	}
	
	public String save(Object o){
		return (String)getHibernateTemplate().save(o);
	}
	
}
